#!/usr/local/bin/python3
# -*- coding: utf-8 -*-

"""
@File    : WaveInterface.py
@Author  : Link
@Time    : 2024/8/6 22:05
@Mark    : Wave生成器类的主要入口
           暂时使用DataFrame数据帧
"""
from pydantic import BaseModel
from FakerDevice.fakerFPGA.digi_variable import PinType

ns = 1
us = 1000
ms = 1000000
s = 1000000000


class BaseClock:
    """
    确认FPGA系统最小时钟单元
    """
    BASE: int = 5
    MAX_UNIT_TIMING: int = 2 ** 32 * BASE


class Pin(BaseModel):
    pinType: int = PinType.IN
    pinDelay: float = 0


class LWaveInterface:
    """
    定义基础分频/最小时钟单元
    用于描绘我需要的波形输出, 便于Verilog语言的编写
    """

    def __init__(self):
        """
        初始化内部成员
        """
        self.ready = False
        self.pinMap = None

    def configBaseClock(self):
        pass

    def configPinMap(self, pin_map: dict):
        if not isinstance(pin_map, dict):
            raise Exception("not isinstance(pin_map, dict)")
        for key, value in pin_map.items():
            if not isinstance(key, str):
                raise Exception("not isinstance(key, str)")
            if not isinstance(value, Pin):
                raise Exception("not isinstance(value, Pin)")
        self.pinMap = pin_map
        self.ready = True

    def preExecute(self):
        pass

    def plot(self):
        """
        使用QT进行Plot
        """
        pass

    def saveAvc(self, avc_name: str):
        """

        """
        pass

    def saveCache(self, key: str):
        """
        缓存到本地数据库中
        """
        pass

    def execute(self):
        pass
